package com.treasure.service.user.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.treasure.service.annotation.LogInfo;
import com.treasure.service.dto.AppVersionCheckResult;
import com.treasure.service.user.service.AppVersionService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
* @Description:    用户基本信息管理
* @Author:         panxinwen
* @CreateDate:     2018/10/15 21:13
* @Version:        1.0
*/
@Api(value = "版本管理",description = "版本管理")
@RestController
@RequestMapping("/version/v1")
public class AppVersionController {
	@Autowired
	private AppVersionService appVersionService;
	
	@LogInfo(log = "客户端检查更新", isPrint = true)
	@ApiOperation(value = "客户端检查更新", notes = "客户端检查更新")
	@PostMapping("/checkUpdate")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "osName", value = "系统名称", required = false, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "versionCode", value = "系统版本号", required = false, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "versionName", value = "系统版本描述", required = false, dataType = "String", paramType = "query") })
	public ResponseEntity<AppVersionCheckResult> checkUpdate(
			@RequestParam(value = "osName") String osName,
			@RequestParam(value = "versionCode") Integer versionCode,
			@RequestParam(value = "versionName",required = false) String versionName) {
		return ResponseEntity.ok(appVersionService.checkUpdate(osName, versionCode));
	}
}
